'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {

	const collection = db.collection('timeline')
	
	// const res=await collection.doc("38d78ca75ed2ed070010c0af514a9e2e").get()
	
	const res=await collection.where({
		content:event.content
	}).get()
		console.log(JSON.stringify(res));
		return {
			code:200,
			msg:'查询成功',
			data:res.data
		}
	//2.1更新update
	// const res=await collection.doc("38d78ca75ed2ed070010c0af514a9e2e").update({
	// 	content:"aaaaaaa"
	// })
	//2.2更新set
	// const res=await collection.doc("48d78ca75ed2ed070010c0af514a9e2e").set({
	// 	content:"set3",
	// 	// time:"time2"
	// })
	
	//3删除
	// let res=await collection.doc("5a93cec95ed2eced000effc02debbfe0").remove();



	// let res0=await collection.add({
	// 	time:"单123",
	// 	content:"单456"
	// })
	// console.log(JSON.stringify(res0));
	
	// let res =await collection.add([{
	// 		time: "123",
	// 		content: "456"
	// 	},
	// 	{
	// 		time: "1123",
	// 		content: "1456"
	// 	}, {
	// 		time: "1123",
	// 		content: "1456"
	// 	}
	// ])

	// console.log(JSON.stringify(res));
	
	//event为客户端上传的参数
	// console.log('event : ' + event)
	//返回数据给客户端
	// return {
	//  code:200,
	//  msg:event.name+'的年龄是'+event.age,
	//  context
	// }
};
